#ifndef DICTIONARYLOOKUP_H
#define DICTIONARYLOOKUP_H

#include <QString>
#include <QList>
#include <QObject>
#include <QRunnable>
#include <QThread>
#include <QSet>

class DictionaryLookupThreaded : public QThread
{
	Q_OBJECT

public:

						DictionaryLookupThreaded(const QString& word, const QString& server);
		void			run();
		static void		checkAndCreateCacheDir();

signals:
		void			gotDefinition(const QString&);


private:
		QString			m_word;
		QString			m_server;
		static QString	m_cacheDirectory;
};

class DictionaryLookup : public QObject
{
	Q_OBJECT

public:
							DictionaryLookup(const QString& word);

	void					performLookup();
	void					performSynonymsLookup();
	QString					getRawLookup() const;
	QString					getRawSynonyms() const;
	bool					exists();

signals:

	void					gotDefinition(DictionaryLookup*);
	void					gotSynonyms(DictionaryLookup*);

private slots:
	void					gotDefinitionSlot(const QString&);
	void					gotSynonymsSlot(const QString&);

private:
	static QSet<QString>	m_words;
	QString					m_word;
	QString					m_dictionaryOutput;
	QString					m_synonymsOutput;
};

#endif // DICTIONARYLOOKUP_H
